﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[RequireComponent(typeof(Dropdown))]
public class UILanguageDropdown : MonoBehaviour
{
    [CompilerGenerated]
    private static Predicate<string> <>f__am$cache1;
    private Dropdown dropdown;

    private void Awake()
    {
        <Awake>c__AnonStorey75 storey = new <Awake>c__AnonStorey75();
        this.dropdown = base.GetComponent<Dropdown>();
        storey.languages = Localization.GetLanguages().ToList<string>();
        this.dropdown.AddOptions(storey.languages);
        if (<>f__am$cache1 == null)
        {
            <>f__am$cache1 = x => x == Localization.Language;
        }
        this.dropdown.value = storey.languages.FindIndex(<>f__am$cache1);
        this.dropdown.onValueChanged.AddListener(new UnityAction<int>(storey.<>m__12E));
    }

    [CompilerGenerated]
    private sealed class <Awake>c__AnonStorey75
    {
        internal List<string> languages;

        internal void <>m__12E(int v)
        {
            Localization.Language = this.languages[v];
            foreach (LocalizableText text in UnityEngine.Object.FindObjectsOfType<LocalizableText>())
            {
                text.Refresh();
            }
        }
    }
}

